package com.huawei.appmarket.service.store.awk.card;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.huawei.appgallery.foundation.card.base.card.BaseDistCard;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appmarket.service.appdetail.bean.detail.DetailFamilySharingCardBean;
import com.huawei.hms.support.api.entity.hwid.HwIDConstant.ACTION;
import com.huawei.hwid.core.constants.HwAccountConstants;
import o.azb;
import o.cgz;
import o.ckt;
import o.Logger;
import o.dof;
import o.ContentManager;
import o.eqx;
import o.ewm.j;

public class DetailFaimlySharingGeneralCard extends BaseDistCard implements OnClickListener {
    private static final Uri ˋ = Uri.parse("content://com.huawei.hwid.api.provider/purchased_share");
    private TextView ʻ;
    private RelativeLayout ʼ;
    private ImageView ʽ;
    private LinearLayout ॱˊ;
    private TextView ॱॱ;
    private ImageView ᐝ;

    public /* synthetic */ cgz ˏ(View view) {
        return ˎ(view);
    }

    public DetailFaimlySharingGeneralCard(Context context) {
        super(context);
    }

    public DetailFaimlySharingGeneralCard ˎ(View view) {
        azb.ˏ(view, j.ʾꜟ);
        this.ʼ = (RelativeLayout) view.findViewById(j.ˑᐝ);
        azb.ˏ(this.ʼ);
        this.ॱˊ = (LinearLayout) view.findViewById(j.ᐝˋ);
        this.ʻ = (TextView) view.findViewById(j.ʼﾞ);
        this.ॱॱ = (TextView) view.findViewById(j.ͺͺ);
        this.ʽ = (ImageView) view.findViewById(j.ˮ);
        this.ᐝ = (ImageView) view.findViewById(j.ˡ);
        this.ʼ.setOnClickListener(new ckt(this));
        ʽ(view);
        return this;
    }

    public void ˏ(CardBean cardBean) {
        DetailFamilySharingCardBean detailFamilySharingCardBean = (DetailFamilySharingCardBean) cardBean;
        if (cardBean != null && !dof.ॱ(detailFamilySharingCardBean.ॱ())) {
            this.ʻ.setText(detailFamilySharingCardBean.ॱ());
            this.ॱॱ.setText(cardBean.O_());
            eqx.ˏ(this.ʽ, detailFamilySharingCardBean.ˊ(), "app_default_icon");
            if (ˋ() && ˎ()) {
                this.ᐝ.setVisibility(0);
                this.ʼ.setClickable(true);
                return;
            }
            this.ᐝ.setVisibility(8);
            this.ʼ.setClickable(false);
        }
    }

    public void onClick(View view) {
        if (view.getId() == j.ˑᐝ) {
            try {
                Intent intent = new Intent();
                intent.setAction(ACTION.HWID_SCHEME_URL);
                intent.setData(Uri.parse("hwid://com.huawei.hwid/FamilyShare"));
                if (this.ʼॱ instanceof Activity) {
                    ((Activity) this.ʼॱ).startActivityForResult(intent, HwAccountConstants.MY_PERMISSIONS_REQUEST_LOCTION);
                }
            } catch (Exception e) {
                Logger.ˏ("DetailFaimlySharingCard", "jump hwid FamilyShare fail");
            }
        }
    }

    private boolean ˎ() {
        boolean equalsIgnoreCase = Build.BRAND.equalsIgnoreCase("huawei");
        Logger.ˎ("DetailFaimlySharingCard", "Brand: " + Build.BRAND);
        if (equalsIgnoreCase) {
            return true;
        }
        equalsIgnoreCase = Build.MANUFACTURER.equalsIgnoreCase("huawei");
        Logger.ˎ("DetailFaimlySharingCard", "Manufacturer: " + Build.MANUFACTURER);
        return equalsIgnoreCase;
    }

    private boolean ˋ() {
        Cursor query;
        Exception e;
        Throwable th;
        try {
            boolean z;
            query = ContentManager.getInstant().getContext().getContentResolver().query(ˋ, null, null, null, null);
            if (query != null) {
                try {
                    if (query.getCount() > 0) {
                        query.moveToFirst();
                        if (query.getInt(query.getColumnIndex("issupport")) == 1) {
                            z = true;
                            if (query != null) {
                                return z;
                            }
                            query.close();
                            return z;
                        }
                    }
                } catch (Exception e2) {
                    e = e2;
                    try {
                        Logger.ˋ("DetailFaimlySharingCard", "isSupportFamilyShare, e: " + e.toString());
                        if (query != null) {
                            return false;
                        }
                        query.close();
                        return false;
                    } catch (Throwable th2) {
                        th = th2;
                        if (query != null) {
                            query.close();
                        }
                        throw th;
                    }
                }
            }
            z = false;
            if (query != null) {
                return z;
            }
            query.close();
            return z;
        } catch (Exception e3) {
            e = e3;
            query = null;
            Logger.ˋ("DetailFaimlySharingCard", "isSupportFamilyShare, e: " + e.toString());
            if (query != null) {
                return false;
            }
            query.close();
            return false;
        } catch (Throwable th3) {
            th = th3;
            query = null;
            if (query != null) {
                query.close();
            }
            throw th;
        }
    }
}
